<?php

$config = [
    // 设置目标语言为中文
    'language' => 'zh-CN',
    'defaultRoute' => 'site/index',
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-backend',
            'cookieValidationKey' => 'e2Rm8ulf0nHQTpsw8Z7jsAuQtMS',//初始化项目后记得更换
            'baseUrl' => '',//不要配 配了之后框架js css路由也会变 除非你要改那一块的引用方式
        ],
        'user' => [
            'identityClass' => 'backend\models\AdminUser',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
        ],
        'errorHandler' => [
            'class' => 'backend\components\AdminErrorHandler'
            // 'class' => 'yii\web\ErrorHandler'
        ],
        'session' => [
            // 使用redis做session
            'name' => "ADMIN-SESSION",
            'class' => 'yii\redis\Session',
            'redis' => 'redis_session',
            // 与后台区分开会话key，保证前后台能同时单独登录
            'timeout' => 86400 * 7,
            'keyPrefix' => 'backend-session:',
            'cookieParams' => ['lifetime' => 86400 * 7, 'httponly' => true],
        ],
    ],
];

if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
    ];
}

return $config;
